package com.java.javadome.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.java.javadome.constant.ActivitesEnum;
import com.java.javadome.dao.TUserDao;
import com.java.javadome.entity.TBill;
import com.java.javadome.entity.TUser;
import com.java.javadome.service.TBillService;
import com.java.javadome.service.TUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * (TUser)表服务实现类
 *
 * @author makejava
 * @since 2023-01-31 10:31:40
 */
@Service("tUserService")
public class TUserServiceImpl extends ServiceImpl<TUserDao, TUser> implements TUserService {
    @Resource
    private TBillService service;

    @Override
    public Object createOrder(ActivitesEnum activities, Integer uid, Long amounts) {
        try {
            this.baseMapper.updateWallet(uid,amounts,activities.getStatus());
        }catch (Exception e){
            e.printStackTrace();
            return "操作失败";
        }
        return service.save(new TBill().setUid(uid)
                .setStatus(activities.getStatus())
                .setActivities(activities.getActivities())
                .setAmounts(amounts)
                .setCreateTime(new Date()));
    }
}

